/**
 * @author wangxiaowei
 * 组织部发文列表
 */
var sort = null;
var grid = null;
var biaoti = '发文查询';
function initzuzhibufawenlist(){
	var state = Ext.get('state').getValue(); 	
	if(state==1){
		biaoti = '党委发文查询';
	}else if(state==2){
		biaoti = '团委发文查询';
	}else if(state==3){
		biaoti = '纪委发文查询';
	}else if(state==4){
		biaoti = '工会发文查询';
	}
			 Ext.BLANK_IMAGE_URL=Ext.get('basePath').getValue()+"ajaxFramework/ext-2.1/resources/images/default/s.gif";
	
Ext.menu.RangeMenu.prototype.icons = {
	  gt: './ajaxFramework/ext-2.1/img/greater_then.png', 
	  lt: './ajaxFramework/ext-2.1/img/less_then.png',
	  eq: './ajaxFramework/ext-2.1/img/equals.png'
	};
Ext.grid.filter.StringFilter.prototype.icon = './ajaxFramework/ext-2.1/img/find.png';
	
var colModel = new Ext.grid.ColumnModel([
		{header:'发文号',dataIndex:'wenhao'},
		{header:'主送机关',dataIndex:'zhusong',menuDisabled : true},
		{header:'标题',dataIndex:'zhaiyao'},		
		{header:'当前环节',dataIndex:'node',menuDisabled : true},	
		{header:'操作',dataIndex:'operate',menuDisabled : true},
		{header:'dutyId',dataIndex:'dutyId',hidden:true}
]);

var filters = new Ext.grid.GridFilters({
		 cleanParams: function(p) {  // 清除参数的方法，要保留PagingToolbar分页用的两个参数
		   //var regex = new RegExp("^" + this.paramPrefix + "\[[0-9]+\]");
		   for(var key in p) {
		      if( key != 'start' && key != 'limit' )
		   //if(regex.test(key)) {
		    delete p[key];
		            //}
		               }
          },
	     buildQuery: function(filters) {	
		  // filters 就是getFilterData返回的值, 代码中push入去的对象
		  var p = {};
		  for(var i=0, len=filters.length; i<len; i++) {
		      var f = filters[i];
		      
		      // 取得在GridFilters中定义的filters中的一个filter
		      var filter = this.getFilter( f.field );
		      // 取得传递到server的参数名称
		      var name = (filter.paramName ? filter.paramName : filter.dataIndex);
		      var value = (filter.paramValue ? filter.paramValue : f.data['value']);
		      
		      if( value != '' ) p[ name ] = value;
		  }
		  return p;
		   },	
		  filters:[
		 	{type: 'string',  dataIndex: 'zhaiyao'},
		 	{type: 'string',  dataIndex: 'wenhao'}
	]}); 
	
	var url = Ext.get('url').getValue();
	sort = new Ext.data.JsonStore({
		url:url,
		fields:['zhaiyao','zhusong','chaosong','fujian','operate','state','wenhao','node'],
		root:'root',
		totalProperty:'totalProperty'
	});
	var bbar = new Ext.PagingToolbar({
		pageSize:23,
		store:sort,
		displayInfo:true,
		plugins: filters,
		emptyMsg:'没有记录'
	});
	
	 grid = new Ext.grid.GridPanel({
		title:biaoti,
		cm:colModel,
		tbar:[{
			 text: '拟稿',
             iconCls: 'silk-add',
              handler:function(){
             	window.location.href=Ext.get('basePath').getValue()+'tjsinfo/tjsoa/dangweifawen/nigaofrom.do'+ "?state="+state;
             }
		}],
		renderTo:'topic-grid',
		store:sort,
		loadMask:true,
		autoHeight:true,
		bbar:bbar,
		plugins: filters,
		viewConfig:{
			forceFit:true,
			getRowClass:function(record,rowIndex,p,ds){
				if(record.get('state') == '是')
				{
					
					return 'red-row';
				}
				else if(record.get('state') == '中止')
				{
					
					return 'yellow-row';
				}
			}
		}
	});
	sort.load({params:{start:parseInt(Ext.get('dangweifajingshourenliststart').getValue()), limit: 23}});	
}




	
	